//
// Created by xili on 2024/8/5 16:34.
// Go big or go home.
//
#include <vector>
#include <iostream>

using namespace std;

class Solution {
public:
    vector<int> numberOfLines(vector<int> &widths, string s) {
        //用两个变量保存当前的行数，和行的大小
        int n = s.size();
        int rowcnts = 1;
        int rowsize = 0;
        for (int i = 0; i < n; i++) {
            int cur = widths[s[i] - 'a'];
            if (rowsize + cur <= 100) {
                rowsize += cur;
            } else {
                rowcnts++;
                rowsize = cur;
            }
        }
        return {rowcnts, rowsize};
    }
};